import type { PropType, ExtractPropTypes } from 'vue';
import tableProps from 'vxe-table/packages/table/src/props';
import { VxeGridPropTypes } from 'vxe-table/types/all';
import GlobalConfig from 'vxe-table/packages/v-x-e-table/src/conf';
import { TableColumn } from './typing';
// import { ProxyAjaxQueryParams } from "vxe-table/types/grid";
import { omit } from 'lodash-es';
import { VxeToolbarProps } from 'vxe-table/types/toolbar';
import { PageSizeItemType } from 'vxe-table/types';
import { FormSchema } from '@/framework/components/core/schema-form';

export enum LayoutMode {
  CLASSIC,
  SIMPLE,
}
export const props = {
  ...omit(tableProps, 'columns'),
  mode: {
    type: Number as PropType<LayoutMode>,
    default: LayoutMode.CLASSIC,
  },
  autoLoad: {
    type: Boolean,
    default: true
  },
  /** 表格列配置 */
  columns: {
    type: Array as PropType<TableColumn<any>[]>,
    required: true,
    default: () => [],
  },

  /** 表格数据请求函数 */
  dataRequest: {
    // 获取列表数据函数API
    type: Function as PropType<
      (params: VxeGridPropTypes.ProxyAjaxQueryParams, data: any) => Promise<API.TableListResult>
    >,
  },
  dataRequestAll: {
    // 获取列表数据函数API
    type: Function as PropType<
      (params: VxeGridPropTypes.ProxyAjaxQueryAllParams, data: any) => Promise<any>
    >,
  },
  search: {
    type: Boolean,
    default: false,
  },
  pager: {
    type: Boolean,
    default: true,
  },
  /** 表格标题 */
  headerTitle: {
    type: String,
    default: '',
  },
  size: {
    type: String as PropType<VxeGridPropTypes.Size>,
    default: () => GlobalConfig.grid.size || GlobalConfig.size,
  },
  /** 工具栏配置 */
  toolbar: {
    type: Object as PropType<VxeToolbarProps>,
    default: () => ({
      custom: true,
      export: true,
    }),
  },
  /** 表单属性配置 */
  formProps: {
    type: Object as PropType<FormSchema>,
    default: () => ({}),
  },
  /** 是否显示表格card title以及action toobar的内容 */
  showCardHeader: {
    type: Boolean,
    default: true,
  },
  remoteFilter: {
    type: Boolean,
    default: false,
  },
  /** 筛选条件表单默认显示的个数 */
  queryFormDefaultShowItemCount: {
    type: Number,
    default: 5,
  },
  pageSizeConfig: {
    type: Array as PropType<PageSizeItemType[]>,
    default: [10, 15, 20, 50, 100],
  },
  /** 搜索框确认按钮类型 */
  searchBtnType: {
    type: String,
    default: 'primary'
  }
};

export type TableProps = ExtractPropTypes<typeof props>;

export default props;
